<?php

namespace app\api\controller;

use app\model\Progress as ProgressModel;
use think\Db;
use think\facade\Log;
use think\facade\Request;

/**
 * @title   进度查询接口
 * @desc    进度查询接口
 * Class Progress
 * @package app\api\controller
 */

class Progress extends Common
{
    /**
     * @title 进度查询
     * @desc  进度查询
     *
     * @param int $title
     * @param int $limit 10
     *
     * @return Array $list 进度查询
     */
    public function jindu()
    {
        // try {
        //     $msg = $this->Auth();
        //     if (!$msg) {
        $limit = $this->request->param('limit');
        $testnum = $this->request->param('testnum');
        if (!$limit) {
            $limit = 10;
        }
        if ($testnum != '') {
            $map[] = ['testnum', 'like', '%' . $testnum . '%'];
        }
        // if ($cname != '') {
        //     $cnamearr[] = ['cname', $cname];
        // }
        $list = ProgressModel::where($map)
            ->field(['id', 'flag', 'signtime', 'starttime', 'completetime', 'sendtime'])
            ->order('id desc')
            ->paginate($limit);
        return $this->jsonPage($list->total(), $list->toArray()['data']);

    }

    /**
     * @title 进度查询
     * @desc  进度查询
     *
     * @param int $title
     * @param int $limit 10
     *
     * @return Array $list 进度查询
     */
    public function authenticity()
    {
        // try {
        //     $msg = $this->Auth();
        //     if (!$msg) {
        $limit = $this->request->param('limit');
        $reportnum = $this->request->param('reportnum');
        $testnum = $this->request->param('testnum');
        $client = $this->request->param('client');
        if (!$limit) {
            $limit = 10;
        }
        if ($reportnum != '') {
            $map[] = ['reportnum', '=', urldecode($reportnum)];
        }
        if ($testnum != '') {
            $map[] = ['testnum', '=', urldecode($testnum)];
        }
        if ($client != '') {
            $map[] = ['client', '=', urldecode($client)];
        }

        // if ($cname != '') {
        //     $cnamearr[] = ['cname', $cname];
        // }
        $list = ProgressModel::where($map)
            ->field(['id', 'flag', 'signtime', 'starttime', 'completetime', 'sendtime'])
            ->order('id desc')
            ->paginate($limit);

        // return ProgressModel::getLastSql();
        return $this->jsonPage($list->total(), $list->toArray()['data']);

    }
}
